import os,string,random

# 获取文件夹下所有文件路径
def get_file_paths(directory):
    file_paths = []
    for root, dirs, files in os.walk(directory):
        for file in files:
            file_paths.append(os.path.join(root, file))
    return file_paths

# 格式化数字为4位
def format_number_four_chars(number):
    return "{:04d}".format(number)

# 获取文件夹下所有文件名
def get_all_names(directory):
    filenames = []
    for root, dirs, files in os.walk(directory):
        for file in files:
            name=os.path.splitext(file)[0]
            filenames.append(name)
    return filenames


def generate_random_string(length=5):
    # 定义可选字符集：包含大小写字母和数字
    characters = string.ascii_letters + string.digits
    # 随机选择指定长度的字符
    random_string = ''.join(random.choice(characters) for _ in range(length))
    return random_string